package cn.uin.config;

import com.aliyun.dysmsapi20170525.Client;
import com.aliyun.teaopenapi.models.Config;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName SMSConfig
 * @Description:短信发送配置
 * @Author: Administrator
 * @CreateDate: 2025/10/29 17:33
 * @Version: 1.0
 */
@Configuration
@EnableConfigurationProperties(SMSConfigProperties.class)
public class SMSConfig {

	public static final String ENDPOINT = "dysmsapi.aliyuncs.com";

	/**
	 * 初始化client
	 * @return
	 * @throws Exception
	 */
	@Bean
	public Client client(SMSConfigProperties smsConfigProperties) throws Exception {
		Config config = new Config();
		config.setAccessKeyId(smsConfigProperties.getAccessKeyId());
		config.setAccessKeySecret(smsConfigProperties.getAccessKeySecret());
		config.setEndpoint(ENDPOINT);
		return new Client(config);
	}

}
